<?php

namespace app\model;

//use support\Model;
use support\Db;
use Illuminate\Database\Eloquent\Model;

class WaOrdersPurchaseOperateLog
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'wa_orders_purchase_operate_log';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    public static function all($condition)
    {
        $list = Db::table('wa_orders_purchase_operate_log')
            ->select('*')
            ->where($condition)
            ->get();
        return json_encode($list);
    }

    public static function created($data){
        $result = Db::table('wa_orders_purchase_operate_log')->insertGetId($data);
        return $result;
    }

    public static function updated($data,$where){
        $result = Db::table('wa_orders_purchase_operate_log')->where($where)->update($data);
        return $result;
    }

    public static function geted($file,$where){
        $result = Db::table('wa_orders_purchase_operate_log')->select($file)->where($where)
            ->get();
        if ($result){
            foreach ($result as $k){
                if ($k->voucher){
                    $k->voucher = json_decode($k->voucher);
                }
            }
        }
        return json_encode($result);
    }

    public static function delete($where){
        $result = Db::table('wa_orders_purchase_operate_log')->where($where)->delete();
        return $result;
    }


}